﻿using AppsModel.APIModel;
using MVC_basic.Models;
using AppsModel.Data_Layer.Concrete;
using MVC_basic.Data_Layer.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using AppsModel.Data_Layer.Interface;
using MVC_basic.Helpers;
using WebMatrix.WebData;

namespace AppsApi.Controllers
{
    public class UsersController : ApiController
    {
        private readonly IdbUser db;
        public UsersController(IdbUser IdbW)
        {
            db = IdbW;
            WebSecurity_Singleton.init();
        }

        public User Get(int id)
        {
            IdbUser db = new dbUser();
            User user = db.getUser(id);
            //APIUser apiuser = APIUser.UserToAPI(user);
            return user;
        }

        public User Get()
        {
            int userId = WebSecurity.GetUserId(User.Identity.Name);
            User user = db.getUser(userId);
            return user;
        }
    }
}
